<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width" />
    <meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
    <title>get_cash</title>
    <link rel="stylesheet" type="text/css" href="../css/aui.css" />
    <link rel="stylesheet" type="text/css" href="../css/font-awesome.min.css" />
    <link rel="stylesheet" type="text/css" href="../css/style.css" />
    <style>
        .aui-list-header {
            height: 2.2rem !important;
            justify-content: flex-start !important;
            -webkit-justify-content: flex-start !important;
        }

        .aui-grid {
            position: fixed;
            z-index: 60;
            top: 0;
            left: 0;
        }

        .aui-grid [class*=aui-col-xs] {
            padding: 0.5rem 0 !important;
        }
        #tab1{
            margin-top: 40px;
        }
    </style>
</head>

<body>
    <div id="tab1">
        <div class="aui-grid">
            <ul class="aui-list aui-form-list">
                <li class="aui-list-header bg-light-gray aui-font-size-14 text-gray">您的可转出余额为&nbsp;<strong class="aui-text-danger" id="CashVal">--</strong>&nbsp;元</li>
                <li class="aui-list-item">
                    <div class="aui-list-item-label aui-font-size-14"><strong class="text-middle-black">转出金额</strong></div>
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-input">
                            <input type="number" placeholder="请输入要转出的金额" class="aui-font-size-14" id="wollet" style="color:#aaa;">
                        </div>
                        <div class="aui-list-item-right aui-padded-r-15">元</div>
                    </div>
                </li>
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-title aui-font-size-14"><strong class="text-middle-black">转入账户</strong></div>
                        <div class="aui-list-item-right aui-padded-r-15">
                          <div class="aui-list-item-input">
                              <select style="color:#aaa;direction: rtl" id="select">


                              </select>
                          </div>
                        </div>
                    </div>
                </li>
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-title aui-font-size-14"><strong class="text-middle-black">可用余额</strong></div>
                        <div class="aui-list-item-right aui-padded-r-15"><span id="mJin">--</span>元</div>
                    </div>
                </li>
            </ul>
        </div>

    </div>
    <div style="position: fixed;bottom: 0;left: 0;width: 100%;height: 2.5rem;text-align: center;line-height: 2.5rem;background: #e14104;color: white;font-size: 5.5vw;" onclick="submit()">提现</div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/aui-tab.js"></script>
<script type="text/javascript" src="../script/request.js"></script>
<script type="text/javascript">
    var accountList;
    apiready = function() {
        getPageData();
    }
	function getPageData(){
		var data = {};
		data['values'] = {};
		data['values']['userId'] = $api.getStorage('userId');
		requestData('Money/pageData',data,'NO','NO','NO',_callbackData);
	}
	function _callbackData(ret){
		if(ret.status == 200){
			$api.text($api.byId('CashVal'), ret.canGetMoney);
			$api.text($api.byId('mJin'), ret.canGetMoney);
      accountList = ret.accountList;
      if(ret.accountList.length>0){
        var html='';
        html+='<option value="">请选择要转入的账户</option>';
        for(var i=0;i<ret.accountList.length;i++){
          html+='<option value="'+i+'">'+ret.accountList[i].type+ret.accountList[i].num+'</option>';
        }
        $api.html($api.byId('select'), html);

      }
		}
	}
	function submit(){
		if(Number($api.val($api.byId('wollet')))<=0){
			alert('请输入提现金额，提现金额不得小于0！');
			return false;
		}
		if(Number($api.val($api.byId('wollet')))>Number($api.text($api.byId('CashVal')))){
			alert('提现金额不得大于可提现金额！');
			return false;
		}
		getMoney();
	}
	function getMoney(){
    var id = $api.val($api.byId('select'));
		var data = {};
		data['values'] = {};
		data['values']['money'] = $api.val($api.byId('wollet'));
		data['values']['userId'] = $api.getStorage('userId');
    data['values']['accountType'] = accountList[id].type;
    data['values']['accountNum'] = accountList[id].num;
		requestData('Money/getMoney',data,'NO','NO','NO',_callbackRelt);
	}
	function _callbackRelt(ret){
    if(ret.status == 200){
      api.toast({
          msg: ret.msg,
          duration: 4000,
          location: 'bottom'
       });
       setTimeout(function(){
         window.location.reload();
       },1000);
    }else{
      api.toast({
          msg: ret.msg,
          duration: 4000,
          location: 'bottom'
       });
    }
	}
</script>

</html>
